package top.yokey.shopnc.activity.mine;

import android.support.v7.widget.AppCompatTextView;
import android.support.v7.widget.LinearLayoutCompat;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.RelativeLayout;

import top.yokey.shopnc.R;
import top.yokey.shopnc.base.BaseApplication;
import top.yokey.base.base.BaseSnackBar;
import top.yokey.shopnc.base.SwipeActivity;

import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.ViewInject;

@ContentView(R.layout.activity_mine_property)
public class PropertyActivity extends SwipeActivity {

    @ViewInject(R.id.mainLinearLayout)
    private LinearLayoutCompat mainLinearLayout;
    @ViewInject(R.id.mainToolbar)
    private Toolbar mainToolbar;
    @ViewInject(R.id.preDepositRelativeLayout)
    private RelativeLayout preDepositRelativeLayout;
    @ViewInject(R.id.preDepositValueTextView)
    private AppCompatTextView preDepositValueTextView;
    @ViewInject(R.id.rechargeCardRelativeLayout)
    private RelativeLayout rechargeCardRelativeLayout;
    @ViewInject(R.id.rechargeCardValueTextView)
    private AppCompatTextView rechargeCardValueTextView;
    @ViewInject(R.id.voucherRelativeLayout)
    private RelativeLayout voucherRelativeLayout;
    @ViewInject(R.id.voucherValueTextView)
    private AppCompatTextView voucherValueTextView;
    @ViewInject(R.id.redPacketRelativeLayout)
    private RelativeLayout redPacketRelativeLayout;
    @ViewInject(R.id.redPacketValueTextView)
    private AppCompatTextView redPacketValueTextView;
    @ViewInject(R.id.pointsRelativeLayout)
    private RelativeLayout pointsRelativeLayout;
    @ViewInject(R.id.pointsValueTextView)
    private AppCompatTextView pointsValueTextView;

    @Override
    public void initData() {

        setToolbar(mainToolbar, "我的财产");

        preDepositValueTextView.setText(BaseApplication.get().getMemberAssetBean().getPredepoit());
        preDepositValueTextView.append("元");
        rechargeCardValueTextView.setText(BaseApplication.get().getMemberAssetBean().getAvailableRcBalance());
        rechargeCardValueTextView.append("元");
        voucherValueTextView.setText(BaseApplication.get().getMemberAssetBean().getVoucher());
        voucherValueTextView.append("张");
        redPacketValueTextView.setText(BaseApplication.get().getMemberAssetBean().getRedpacket());
        redPacketValueTextView.append("个");
        pointsValueTextView.setText(BaseApplication.get().getMemberAssetBean().getPoint());
        pointsValueTextView.append("分");

    }

    @Override
    public void initEven() {

        preDepositRelativeLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (BaseApplication.get().getMemberAssetBean() == null) {
                    BaseSnackBar.get().showHandler(mainLinearLayout);
                    return;
                }
                BaseApplication.get().startCheckLogin(getActivity(), PreDepositActivity.class);
            }
        });

        rechargeCardRelativeLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (BaseApplication.get().getMemberAssetBean() == null) {
                    BaseSnackBar.get().showHandler(mainLinearLayout);
                    return;
                }
                BaseApplication.get().startCheckLogin(getActivity(), RechargeCardActivity.class);
            }
        });

        voucherRelativeLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (BaseApplication.get().getMemberAssetBean() == null) {
                    BaseSnackBar.get().showHandler(mainLinearLayout);
                    return;
                }
                BaseApplication.get().startCheckLogin(getActivity(), VoucherActivity.class);
            }
        });

        redPacketRelativeLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (BaseApplication.get().getMemberAssetBean() == null) {
                    BaseSnackBar.get().showHandler(mainLinearLayout);
                    return;
                }
                BaseApplication.get().startCheckLogin(getActivity(), RedPacketActivity.class);
            }
        });

        pointsRelativeLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (BaseApplication.get().getMemberAssetBean() == null) {
                    BaseSnackBar.get().showHandler(mainLinearLayout);
                    return;
                }
                BaseApplication.get().startCheckLogin(getActivity(), PointsActivity.class);
            }
        });

    }

}
